{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "downloader, INFO http://base.ustc.edu.cn/data/cdbd/a0910/item.csv is saved as ../../data/a0910/item.csv\n",
      "downloader, INFO file existed, skipped\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'../../data'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from EduData import get_data\n",
    "\n",
    "get_data(\"cdbd-a0910\", \"../../data\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "path_prefix = '../../data/a0910/'\n",
    "train_data = pd.read_csv(f'{path_prefix}train.csv',\n",
    "                         encoding=\"utf-8\", low_memory=False)\n",
    "valid_data = pd.read_csv(f'{path_prefix}valid.csv',\n",
    "                         encoding=\"utf-8\", low_memory=False)\n",
    "test_data = pd.read_csv(f'{path_prefix}test.csv',\n",
    "                        encoding=\"utf-8\", low_memory=False)\n",
    "data = train_data.append([valid_data, test_data])\n",
    "# 保留作答题目大于15的学生\n",
    "group = data.groupby(['item_id'], as_index=False)\n",
    "df = pd.DataFrame(columns=['user_id', 'item_id', 'score'])\n",
    "for i in group:\n",
    "    if len(i[1]) >= 15:\n",
    "        df = df.append([i[1]])\n",
    "df.to_csv(f'{path_prefix}log.csv', index=None)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.9.7 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "30cf1c0bf0a8c24a67f341fa01023997b228873b5bd061707cfd99d0cfb90c8a"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
